package com.ts.audioplayer

import android.util.Log
import com.ts.audioplayer.listener.IPlayerListener
import com.ts.audioplayer.listener.MNOnParparedListener

class TsPlayer {
    var mnoOnParparedListener: MNOnParparedListener? = null
    init{
        System.loadLibrary("audiocamera")
    }
    external fun n_seek(secds:Int)

    external fun n_resume()

    external fun n_mute(mute:Int)

    external fun n_volume(percent:Int)

    external fun n_pause();
//    external fun n_play();
    external fun n_start()
    external fun prepare(source:String)

     var source: String? = null //数据源

    fun start(){
        if (source?.isEmpty() == true){
            return
        }
        Thread{
            Log.e(TAG,"n_start")
            n_start();
        }.start()
    }


    fun prepare(){
        if (source?.isEmpty() == true){
            return
        }
        Thread{
            prepare(source!!);
        }.start()
    }
    public fun onCallTimeInfo(currentTime: Int, totalTime: Int){
        Log.e(TAG,"onCallTimeInfo")
        if (mnoOnParparedListener == null) {
            return
        }

    }
    private  val TAG = "TsPlayer"

    public fun onCallParpared() {
        Log.e(TAG,"onCallParpared")
        if (mnoOnParparedListener==null){
            Log.e(TAG,"onCallParpared null")
        }
//        if (mnOnParparedListener != null) {
        mnoOnParparedListener?.onParpared()
//        }

    }
     var playerListener: IPlayerListener? = null
//    var mnOnParparedListener: MNOnParparedListener? = null

}